<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla modelitem library
jimport('joomla.application.component.modelitem');

class ShopModelLogo extends JModelItem
{

	/**
	 * Method to auto-populate the model state.
	 *
	 * Note. Calling getState in this method will result in recursion.
	 *
	 * return	void
	 * @since	1.6
	 */
	protected $_pagination = null;
	protected function populateState($ordering = null, $direction = null)
	{
		// Initiliase variables.
		$app	= JFactory::getApplication('site');
	
		// Load the parameters. Merge Global and Menu Item params into new object
		$params = $app->getParams();
		$menuParams = new JRegistry;

		if ($menu = $app->getMenu()->getActive()) {
			$menuParams->loadString($menu->params);
		}

		$mergedParams = clone $menuParams;
		$mergedParams->merge($params);

		$this->setState('params', $mergedParams);
		$user		= JFactory::getUser();
		// Create a new query object.
		$this->setState('list.start', JRequest::getVar('limitstart', 0, '', 'int'));
		$this->setState('list.limit', $params->get('display_num',20));
		$this->setState('product.widthimg',$params->get('widthimg',150));
		$this->setState('product.heightimg',$params->get('heightimg',150));
		$this->setState('page.columns',$params->get('columns',3));
		$this->setState('sort',$params->get('sort','id'));
		$this->setState('sortdir',$params->get('sortdir','DESC'));		
		$this->setState('page.show_page_heading',$params->get('show_page_heading',0));
		$this->setState('page.page_title',$params->get('page_title','No Title'));
		
				
	}
	/*
	*	get item products
	*	call get item products
	*/
	function getItems()
	{
		$params 	= $this->getState()->get('params');
		$limitstart =  $this->getState('list.start');
		$limit 		= $this->getState('list.limit');
		
		$db =& JFactory::getDBO();
		$query = $db->getQuery(true);
		$query->clear();
		$query->select('count(*)');
		$query->from('#__shop_product');
		$query->where('state = 1');
		
		$db->setQuery((string)$query);
		$total = $db->loadResult();
		jimport('joomla.html.pagination');
		$this->_pagination = new JPagination( $total, $limitstart, $limit ); 
		
		$query->clear();
		$query->select('*');
		$query->from('#__shop_product');
		$query->where('state = 1');
		
		$db->setQuery((string)$query, $this->_pagination->limitstart , $this->_pagination->limit);
		$items = $db->loadObjectList();

		return $items;
	}
	/*
	*
	*	get pagination
	*/
	public function getPagination()
	{
		if (empty($this->_pagination)) {
			return null;
		}
		return $this->_pagination;
	}
	/*
	* get Category and sub child
	**/
	
}